General architectural questions
-
Hello,
we develop disinfection devices. Those devices have a screen, roughly 18cm in size. Internally, they have a Raspberry PI 5. The disinfection devices communicate wirelessly with sensor units via the MQTT protocol. We are about to completely rewrite the old legacy software and Qt would be an obvious choice.Should the new software completely be written and integrated into the Qt framework, i.e., frontend and backend?
The wireless communication with the sensors is critical to the disinfection process. Is it safe to integrate it into Qt as well, i.e. have one main entry point for the whole software, a.ka. a main.py file, which then starts the MQTT communication with the sensors, etc.?Another question is about the flow of data. The sensor data (such as temperature, humidity) is captured by our sensor units, and we want to display those data on our screen (both during the disinfection process and outside of it). Additionally, our disinfection device generates reports at the end of a disinfection process, to visually depict the process and display key data. For our reports, we only need data points in a 1-minute interval, as this is enough. However, to show them on the display, we want to update the sensor data roughly every 2 seconds (for now). Once the data is captured in a "MQTT process" on the Raspberry PI 5, should it first be saved on the database (where each write every 2 seconds may contain 20 records/rows or more), and then read from the database to display the values on the screen? Or, is it safe and more appropriate to directly display values on the screen, and only save the sensor data for each minute (as this is necessary for the reports)?
Additional Info: Since we do not have any high performance criteria (seconds are important, not milliseconds or mikroseconds), we would completely write it in Python with PySide6. This should be no issue I suppose.
Thanks!
-
Hello,
we develop disinfection devices. Those devices have a screen, roughly 18cm in size. Internally, they have a Raspberry PI 5. The disinfection devices communicate wirelessly with sensor units via the MQTT protocol. We are about to completely rewrite the old legacy software and Qt would be an obvious choice.Should the new software completely be written and integrated into the Qt framework, i.e., frontend and backend?
The wireless communication with the sensors is critical to the disinfection process. Is it safe to integrate it into Qt as well, i.e. have one main entry point for the whole software, a.ka. a main.py file, which then starts the MQTT communication with the sensors, etc.?Another question is about the flow of data. The sensor data (such as temperature, humidity) is captured by our sensor units, and we want to display those data on our screen (both during the disinfection process and outside of it). Additionally, our disinfection device generates reports at the end of a disinfection process, to visually depict the process and display key data. For our reports, we only need data points in a 1-minute interval, as this is enough. However, to show them on the display, we want to update the sensor data roughly every 2 seconds (for now). Once the data is captured in a "MQTT process" on the Raspberry PI 5, should it first be saved on the database (where each write every 2 seconds may contain 20 records/rows or more), and then read from the database to display the values on the screen? Or, is it safe and more appropriate to directly display values on the screen, and only save the sensor data for each minute (as this is necessary for the reports)?
Additional Info: Since we do not have any high performance criteria (seconds are important, not milliseconds or mikroseconds), we would completely write it in Python with PySide6. This should be no issue I suppose.
Thanks!
Hi and welcome,
@adhn said in General architectural questions:
Should the new software completely be written and integrated into the Qt framework, i.e., frontend and backend?
both is possible. You can write a non-Qt app / backend and slap a Qt frontend onto it... or you start with Qt from the beginning and throughout.
The wireless communication with the sensors is critical to the disinfection process. Is it safe to integrate it into Qt as well, i.e. have one main entry point for the whole software, a.ka. a main.py file, which then starts the MQTT communication with the sensors, etc.?
If you chose the latter approach and write a new "Qt app", you can also use Qt's other modules like
QMqtt
... this reduces the amount of 3rd party stuff needed for your app.Or, is it safe and more appropriate to directly display values on the screen, and only save the sensor data for each minute (as this is necessary for the reports)?
This is also hard to tell from outstander's perspective. Both ways are possible.
You can either display "live" data, as the interval (0.5 Hz) is far from being too frequent or you read the data from DB...
Or... as I write this, I thought of buffering the data so you don't need to write to DB every 2s.... Store chunks of data, write to DB in even lower intervals and display the buffered live data that's on your RPi.@adhn said in General architectural questions:
Since we do not have any high performance criteria (seconds are important, not milliseconds or mikroseconds), we would completely write it in Python with PySide6. This should be no issue I suppose.
No usually not. The Python wrapper PySide is officially supported and migrates almost all features of Qt to Python...
Don't know from the top of my head if this is the case for theQMQTT
module... but should work. And if not, you can still use another MQTT implementation. -
Hi and welcome,
@adhn said in General architectural questions:
Should the new software completely be written and integrated into the Qt framework, i.e., frontend and backend?
both is possible. You can write a non-Qt app / backend and slap a Qt frontend onto it... or you start with Qt from the beginning and throughout.
The wireless communication with the sensors is critical to the disinfection process. Is it safe to integrate it into Qt as well, i.e. have one main entry point for the whole software, a.ka. a main.py file, which then starts the MQTT communication with the sensors, etc.?
If you chose the latter approach and write a new "Qt app", you can also use Qt's other modules like
QMqtt
... this reduces the amount of 3rd party stuff needed for your app.Or, is it safe and more appropriate to directly display values on the screen, and only save the sensor data for each minute (as this is necessary for the reports)?
This is also hard to tell from outstander's perspective. Both ways are possible.
You can either display "live" data, as the interval (0.5 Hz) is far from being too frequent or you read the data from DB...
Or... as I write this, I thought of buffering the data so you don't need to write to DB every 2s.... Store chunks of data, write to DB in even lower intervals and display the buffered live data that's on your RPi.@adhn said in General architectural questions:
Since we do not have any high performance criteria (seconds are important, not milliseconds or mikroseconds), we would completely write it in Python with PySide6. This should be no issue I suppose.
No usually not. The Python wrapper PySide is officially supported and migrates almost all features of Qt to Python...
Don't know from the top of my head if this is the case for theQMQTT
module... but should work. And if not, you can still use another MQTT implementation.@Pl45m4
Hi, thank you for your response.
For the 2 main questions:
*) One Qt-app vs non-Qt backend with a Qt frontend
*) Data flow (display "live" data directly, or write and read everything via a database every few seconds)I was looking for some guidance/recommendations. What are the best practices regarding those 2 questions, and what would make more sense? Can you say that one way is "better" than the other (in terms of security, stability and maintainability), or is it more like a matter of taste?
One more question: Are there any preferences regarding on how to structure the software when developing a Qt application (either for one Qt-app or for a non Qt-backend with a Qt frontend) , e.g. MVC vs MVVM?
-
@Pl45m4
Hi, thank you for your response.
For the 2 main questions:
*) One Qt-app vs non-Qt backend with a Qt frontend
*) Data flow (display "live" data directly, or write and read everything via a database every few seconds)I was looking for some guidance/recommendations. What are the best practices regarding those 2 questions, and what would make more sense? Can you say that one way is "better" than the other (in terms of security, stability and maintainability), or is it more like a matter of taste?
One more question: Are there any preferences regarding on how to structure the software when developing a Qt application (either for one Qt-app or for a non Qt-backend with a Qt frontend) , e.g. MVC vs MVVM?
@adhn said in General architectural questions:
I was looking for some guidance/recommendations. What are the best practices regarding those 2 questions, and what would make more sense?
As I've said, both ways are possible. It's just a matter of taste whether you go "all-in" on Qt modules or still have a plain Python app with more 3rd party things and use Qt only for the UI window.
What approach you pick for your data handling depends on what your goal is... what should be possible using the UI?!... does the UI always have to be in sync with the database?!... or is it fine for you to live stream the data while in the background it is buffered and written to the DB in different intervals?!
In which direction you should go only can be answered by people with in-depth knowledge of what's going on exactly.
Your first described way (writing to DB and showing data the same time) only works as long as your data intervals are low... if, for some reason it might increase in the future, it can cause issues... flooding the DB with high-frequency read/write access might not be the best idea
Therefore introducing some kind of buffering on the device works best, I think... Then think about how you handle device/sensor failures... how important is it to store every single value in the DB?! What happens if the device crashes while/before writing the current (buffered) data to DB?@adhn said in General architectural questions:
One more question: Are there any preferences regarding on how to structure the software when developing a Qt application (either for one Qt-app or for a non Qt-backend with a Qt frontend) , e.g. MVC vs MVVM?
I think it also depends on the style of your GUI...
I can speak mostly for C++ / QtWidgets, whoseModel / View
pattern follows a more or less simple MVC approach.
And in addition you have optional item delegates, so it could become "MVC/(D)"...AFAIK QtQuick / QML supports also "higher level" designs and patterns. But it's all a matter of how you implement your logic.
BTW this is also a question that you should ask yourself (or people in charge for the design of your app):
How "fancy" and design-oriented your app/GUI should be.
PySide works with Qt Widgets as well as it supports QtQuick integration (I've never used it though)